<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/6/8
 * Time: 下午1:55
 */

include_once '2.php';

br();


function generateCallTrace()
{
    $e = new Exception();
    $trace = explode("\n", $e->getTraceAsString());
    // reverse array to make steps line up chronologically
    $trace = array_reverse($trace);
    array_shift($trace); // remove {main}
    array_pop($trace); // remove call to this method
    $length = count($trace);
    $result = array();

    for ($i = 0; $i < $length; $i++) {
        $result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i],
                ' ')); // replace '#someNum' with '$i)', set the right ordering
    }

    return "\t" . implode("\n\t", $result);
}

var_dump(generateCallTrace());
echo (new Exception("fuck",12,null))->getCode();